<template>
  <a-card :bordered="false">
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd_" type="primary" icon="plus">新增</a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <tpmActDetail-modal :categoriesCode="this.categoriesCode"
                       :tempUuid ="this.tempUuid" ref="modalForm" @ok="modalFormOk"></tpmActDetail-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import TpmActDetailModal from './modules/TpmActDetailModal'
  import { PageListMixin } from '@/mixins/PageListMixin'

  export default {
    name: "TpmActDetailList",
    mixins:[PageListMixin],
    props:['categoriesCode','tempUuid'],
    components: {
      TpmActDetailModal
    },
    data () {
      return {
        description: '活动明细管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          },
		   {
            title: '活动明细编号',
            align:"center",
            dataIndex: 'actDetailCode'
           },
          {
            title: '活动细类编码',
            align:"center",
            dataIndex: 'categoriesDetailCode'
          },
          {
            title: '活动细类名称',
            align:"center",
            dataIndex: 'categoriesDetailName'
          },
		   {
            title: '客户编码',
            align:"center",
            dataIndex: 'customerCode'
           },
		   {
            title: '客户名称',
            align:"center",
            dataIndex: 'customerName'
           },
		   {
            title: '门店编码',
            align:"center",
            dataIndex: 'terminalCode'
           },
		   {
            title: '门店名称',
            align:"center",
            dataIndex: 'terminalName'
           },

		   {
            title: '申请金额',
            align:"center",
            dataIndex: 'amount'
           },
		   {
            title: '支付方式',
            align:"center",
            dataIndex: 'payType_dictText'
           },
		   {
            title: '预估销售额(客户)',
            align:"center",
            dataIndex: 'fsalesAmountCustomer'
           },
		   {
            title: '预估销售额(门店)',
            align:"center",
            dataIndex: 'fsalesAmountTerminal'
           },

          {
            title: '备注',
            align:"center",
            dataIndex: 'remarks'
          },
        ],
		url: {
          list:window._CONFIG['domianTpmURL']+ "/act/tpmActDetail/findPageList",
          delete:window._CONFIG['domianTpmURL']+ "/act/tpmActDetail/delete",
          deleteBatch:window._CONFIG['domianTpmURL']+ "/act/tpmActDetail/deleteBatch",
          exportXlsUrl: "act/tpmActDetail/exportXls",
          importExcelUrl: "act/tpmActDetail/importExcel",
       },
    }
  },
    created() {
      this.queryParam.tempUuid = this.tempUuid
    },
    computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {
      handleAdd_: function() {
        if (this.categoriesCode && typeof this.categoriesCode === 'function') {
          const result = this.categoriesCode()
          if (result == undefined || !result) {
            this.$message.warning('请选择活动大类！');
            return false;
          }
        } else if (this.categoriesCode == undefined || this.categoriesCode == '') {
            this.$message.warning('请选择活动大类！');
            return false;
        }


        this.$refs.modalForm.add();
        this.$refs.modalForm.title = "新增";
        this.$refs.modalForm.disableSubmit = false;
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>